import request from "@/utils/request";


// 添加组别
export function addGroup(data: any) {
  return request<number>({
    url: "/GroupMaster/Add",
    method: "POST",
    data
  });
}
// 分页查询
export function GetPageGroup( pageNum: number, pageSize: number ,search: any) {
  return request({
    url: "/GroupMaster/GetPageGroup",
    method: "POST",
    data: {
      pageNum,
      pageSize,
      search// QueryUser 对象
    }
  });
}



// 更新组别
export function updateGroup(data: any) {
  return request<boolean>({
    url: "/GroupMaster/Update",
    method: "PUT",
    data
  });
}

// 删除组别
export function deleteGroup(groupId: number) {
  return request<boolean>({
    url: `/GroupMaster/Delete/${groupId}`,
    method: "DELETE"
  });
}

// 获取组别详情
export function getGroupById(groupId: number) {
  return request<any>({
    url: `/GroupMaster/GetById/${groupId}`,
    method: "GET"
  });
}

// 获取所有组别
export function getGroupList() {
  return request<any[]>({
    url: "/GroupMaster/GetAll",
    method: "GET"
  });
}

// 按分类获取组别
export function getGroupsByCategory(category: string) {
  return request<any[]>({
    url: `/GroupMaster/GetByCategory/${category}`,
    method: "GET"
  });
}

// 切换组别状态
export function toggleGroupStatus(groupId: number, isActive: string) {
  return request<boolean>({
    url: `/GroupMaster/ToggleStatus/${groupId}`,
    method: "POST",
    data: { isActive }
  });
}
// 获取所有组别
export function getAllGroups() {
  return request<any[]>({
    url: "/GroupMaster/GetAll",
    method: "GET"
  });
}
// 获取用户所属组别
export function getGroupsByUser(userId: string) {
  return request<any[]>({
    url: `/GroupMaster/GetByUser/${userId}`,
    method: "GET"
  });
}